#define led (11)
#define TEMP0 (10)
#define TEMP1 (60)
#define ADC0 (297)
#define ADC1 (168)
const int analogOutPin = 11;

void setup() {
  // put your setup code here, to run once:
pinMode(led, OUTPUT);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
short int n = analogRead(A0);
Serial.println(convert_adc2temperature(n,ADC0,ADC1,TEMP0,TEMP1));
delay(10);
analogWrite(analogOutPin,convert_adc2temperature(n,ADC0,ADC1,TEMP0,TEMP1)*4);



}
short int convert_adc2temperature(
   short int ax,
   short int a0,short int a1,
   short int temp0,short int temp1)
{
   short int tempx;
   tempx = temp0+(ax/2-a0)*(temp1-temp0)/(a1-a0);
   return tempx;
}
